home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
c01oop.zip
/
CPPWKBK
/
CPPV4-2.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-25
|
868b
|
47 lines
#define HEADER "C++ Problem 4.2 by Rick Conn using Borland C++"
#include <stdio.h>
class number {
protected:
int value;
public:
number (int new_value = 0);
void set (int new_value = 0);
};
class pnumber : public number {
public:
// Note: I had to add a constructor for pnumber
// because number's constructor required an argument
pnumber (int new_value = 0);
void print(void);
};
number::number(int new_value) {
value = new_value;
}
void number::set (int new_value) {
value = new_value;
}
pnumber::pnumber(int new_value) {
value = new_value;
}
void pnumber::print (void) {
printf("The value is %d\n", value);
}
void main(void)
{
printf("%s\n", HEADER);
pnumber a (12), b(20), c(0);
a.print(); b.print(); c.print();
a.set(1); b.set(2); c.set(3);
a.print(); b.print(); c.print();
}